package com.xuecheng.api;

import com.xuecheng.content.service.TeachPlanService;
import com.xuecheng.module.dto.SaveTeachplanDto;
import com.xuecheng.module.dto.TeachPlanDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 星河一叶Ck
 * @date 2025/4/22
 */

@Api(value = "课程计划编辑接口", tags = "课程计划编辑接口")
@RestController
@RequiredArgsConstructor
public class TeachplanController {
    private final TeachPlanService teachPlanService;

    /**
     * 根据课程id查询课程计划
     * @param courseId 课程id
     * @return 课程计划
     */
    @ApiOperation("查询课程计划树形结构")
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeachPlanDto> getTreeNodes(@PathVariable Long courseId) {
        return teachPlanService.getTreeNodes(courseId);
    }

    /**
     * 新增/修改/保存课程计划
     * @param saveTeachplanDto 保存课程计划
     */
    @ApiOperation("新增/修改/保存课程计划")
    @PostMapping("/teachplan")
    public void saveTeachplan (@RequestBody SaveTeachplanDto saveTeachplanDto) {
        teachPlanService.saveTeachplan(saveTeachplanDto);
    }

    /**
     * 删除课程计划
     * @param id 课程计划id
     */
    @DeleteMapping("/teachplan/{id}")
    public void deleteTeachPlan (@PathVariable Long id) {
        teachPlanService.deleteTeachPlan(id);
    }
}
